<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">



<ul id="index">
  <li><a href="#Name">Name</a></li>
  <li><a href="#Installation">Installation</a></li>
  <li><a href="#Synopsis">Synopsis</a></li>
  <li><a href="#Description">Description</a></li>
  <li><a href="#Directives">Directives</a>
    <ul>
      <li><a href="#ngx_tcp_module">ngx_tcp_module</a>
        <ul>
          <li><a href="#tcp">tcp</a></li>
          <li><a href="#server">server</a></li>
          <li><a href="#listen">listen</a></li>
          <li><a href="#access_log">access_log</a></li>
          <li><a href="#allow">allow</a></li>
          <li><a href="#deny">deny</a></li>
          <li><a href="#so_keepalive">so_keepalive</a></li>
          <li><a href="#tcp_nodelay">tcp_nodelay</a></li>
          <li><a href="#timeout">timeout</a></li>
          <li><a href="#server_name">server_name</a></li>
          <li><a href="#resolver">resolver</a></li>
          <li><a href="#resolver_timeout">resolver_timeout</a></li>
        </ul>
      </li>
      <li><a href="#ngx_tcp_upstream_module">ngx_tcp_upstream_module</a>
        <ul>
          <li><a href="#upstream">upstream</a></li>
          <li><a href="#server1">server</a></li>
          <li><a href="#check">check</a></li>
          <li><a href="#check_http_send">check_http_send</a></li>
          <li><a href="#check_http_expect_alive">check_http_expect_alive</a></li>
          <li><a href="#check_smtp_send">check_smtp_send</a></li>
          <li><a href="#check_smtp_expect_alive">check_smtp_expect_alive</a></li>
          <li><a href="#check_shm_size">check_shm_size</a></li>
          <li><a href="#tcp_check_status">tcp_check_status</a></li>
          <li><a href="#busyness">busyness</a></li>
          <li><a href="#ip_hash">ip_hash</a></li>
        </ul>
      </li>
      <li><a href="#ngx_tcp_proxy_module">ngx_tcp_proxy_module</a>
        <ul>
          <li><a href="#proxy_pass">proxy_pass</a></li>
          <li><a href="#proxy_buffer">proxy_buffer</a></li>
          <li><a href="#proxy_connect_timeout">proxy_connect_timeout</a></li>
          <li><a href="#proxy_read_timeout">proxy_read_timeout</a></li>
          <li><a href="#proxy_send_timeout">proxy_send_timeout</a></li>
        </ul>
      </li>
      <li><a href="#ngx_tcp_websocket_module">ngx_tcp_websocket_module</a>
        <ul>
          <li><a href="#websocket_pass">websocket_pass</a></li>
          <li><a href="#websocket_buffer">websocket_buffer</a></li>
          <li><a href="#websocket_connect_timeout">websocket_connect_timeout</a></li>
          <li><a href="#websocket_read_timeout">websocket_read_timeout</a></li>
          <li><a href="#websocket_send_timeout">websocket_send_timeout</a></li>
        </ul>
      </li>
      <li><a href="#ngx_tcp_ssl_module">ngx_tcp_ssl_module</a>
        <ul>
          <li><a href="#ssl">ssl</a></li>
          <li><a href="#ssl_certificate">ssl_certificate</a></li>
          <li><a href="#ssl_certificate_key">ssl_certificate_key</a></li>
          <li><a href="#ssl_client_certificate">ssl_client_certificate</a></li>
          <li><a href="#ssl_dhparam">ssl_dhparam</a></li>
          <li><a href="#ssl_ciphers">ssl_ciphers</a></li>
          <li><a href="#ssl_crl">ssl_crl</a></li>
          <li><a href="#ssl_prefer_server_ciphers">ssl_prefer_server_ciphers</a></li>
          <li><a href="#ssl_protocols">ssl_protocols</a></li>
          <li><a href="#ssl_verify_client">ssl_verify_client</a></li>
          <li><a href="#ssl_verify_depth">ssl_verify_depth</a></li>
          <li><a href="#ssl_session_cache">ssl_session_cache</a></li>
          <li><a href="#ssl_session_timeout">ssl_session_timeout</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="#Compatibility">Compatibility</a></li>
  <li><a href="#Notes">Notes</a></li>
  <li><a href="#TODO">TODO</a></li>
  <li><a href="#Known-Issues">Known Issues</a></li>
  <li><a href="#Changelogs">Changelogs</a>
    <ul>
      <li><a href="#v0.2.0">v0.2.0</a></li>
      <li><a href="#v0.19">v0.19</a></li>
      <li><a href="#v0.1">v0.1</a></li>
    </ul>
  </li>
  <li><a href="#Authors">Authors</a></li>
  <li><a href="#Copyright-License">Copyright &amp; License</a></li>
</ul>

<h1 id="Name">Name</h1>

<p><b>nginx_tcp_proxy_module</b> - support TCP proxy with Nginx</p>

<h1 id="Installation">Installation</h1>

<p>Download the latest stable version of the release tarball of this module from github (<a href="http://github.com/yaoweibin/nginx_tcp_proxy_module">http://github.com/yaoweibin/nginx_tcp_proxy_module</a>)</p>

<p>Grab the nginx source code from nginx.org (<a href="http://nginx.org/">http://nginx.org/</a>), for example, the version 1.20.2 (see nginx compatibility), and then build the source with this module:</p>

<pre><code>    $ wget &#39;http://nginx.org/download/nginx-1.20.2.tar.gz&#39;
    $ tar -xzvf nginx-1.20.2.tar.gz
    $ cd nginx-1.20.2/
    $ patch -p1 &lt; /path/to/nginx_tcp_proxy_module/tcp.patch

    $ ./configure --add-module=/path/to/nginx_tcp_proxy_module

    $ make
    $ make install</code></pre>

<h1 id="Synopsis">Synopsis</h1>

<p>http {</p>

<pre><code>    server {
        listen 80;

        location /status {
            tcp_check_status;
        }
    }
}</code></pre>

<p>#You can also include tcp_proxy.conf file individually</p>

<p>#include /path/to/tcp_proxy.conf;</p>

<p>tcp {</p>

<pre><code>    upstream cluster {
        # simple round-robin
        server 192.168.0.1:80;
        server 192.168.0.2:80;

        check interval=3000 rise=2 fall=5 timeout=1000;

        #check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;

        #check interval=3000 rise=2 fall=5 timeout=1000 type=http;
        #check_http_send &quot;GET / HTTP/1.0\r\n\r\n&quot;;
        #check_http_expect_alive http_2xx http_3xx;
    }

    server {
        listen 8888;

        proxy_pass cluster;
    }
}</code></pre>

<h1 id="Description">Description</h1>

<p>This module actually include many modules: ngx_tcp_module, ngx_tcp_core_module, ngx_tcp_upstream_module, ngx_tcp_proxy_module, ngx_tcp_websocket_module, ngx_tcp_ssl_module, ngx_tcp_upstream_ip_hash_module. All these modules work together to support TCP proxy with Nginx. I also added other features: ip_hash, upstream server health check, status monitor.</p>

<p>The motivation of writing these modules is Nginx&#39;s high performance and robustness. At first, I developed this module just for general TCP proxy. And now, this module is frequently used in websocket reverse proxying.</p>

<p>Note, You can&#39;t use the same listening port with HTTP modules.</p>

<h1 id="Directives">Directives</h1>

<h2 id="ngx_tcp_module">ngx_tcp_module</h2>

<h3 id="tcp">tcp</h3>

<p><b>syntax:</b> <i>tcp {...}</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>main</i></p>

<p><b>description:</b> All the tcp related directives are contained in the tcp block.</p>

<p><b>ngx_tcp_core_module</b></p>

<h3 id="server">server</h3>

<p><b>syntax:</b> <i>server {...}</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp</i></p>

<p><b>description:</b> All the specific server directives are contained in the server block.</p>

<h3 id="listen">listen</h3>

<p><b>syntax:</b> <i>listen address:port [ bind | ssl | default]</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>server</i></p>

<p><b>description:</b> The same as listen (<a href="http://wiki.nginx.org/NginxMailCoreModule#listen">http://wiki.nginx.org/NginxMailCoreModule#listen</a>). The parameter of default means the default server if you have several server blocks with the same port.</p>

<h3 id="access_log">access_log</h3>

<p><b>syntax:</b> <i>access_log path [buffer=size] | off</i></p>

<p><b>default:</b> <i>access_log logs/tcp_access.log</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> Set the access.log. Each record&#39;s format is like this:</p>

<p>log_time worker_process_pid client_ip host_ip accept_time upstream_ip bytes_read bytes_write</p>

<p>2011/08/02 06:19:07 [5972] 127.0.0.1 0.0.0.0:1982 2011/08/02 06:18:19 172.19.0.129:80 80 236305</p>

<ul>

<li><p><i>log_time</i>: The current time when writing this log. The log action is called when the proxy session is closed.</p>

</li>
<li><p><i>worker_process_pid</i>: the pid of worker process</p>

</li>
<li><p><i>client_ip</i>: the client ip</p>

</li>
<li><p><i>host_ip</i>: the server ip and port</p>

</li>
<li><p><i>accept_time</i>: the time when the server accepts client&#39;s connection</p>

</li>
<li><p><i>upstream_ip</i>: the upstream server&#39;s ip</p>

</li>
<li><p><i>bytes_read</i>: the bytes read from client</p>

</li>
<li><p><i>bytes_write</i>: the bytes written to client</p>

</li>
</ul>

<h3 id="allow">allow</h3>

<p><b>syntax:</b> <i>allow [ address | CIDR | all ]</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>server</i></p>

<p><b>description:</b> Directive grants access for the network or addresses indicated.</p>

<h3 id="deny">deny</h3>

<p><b>syntax:</b> <i>deny [ address | CIDR | all ]</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>server</i></p>

<p><b>description:</b> Directive grants access for the network or addresses indicated.</p>

<h3 id="so_keepalive">so_keepalive</h3>

<p><b>syntax:</b> <i>so_keepalive on|off</i></p>

<p><b>default:</b> <i>off</i></p>

<p><b>context:</b> <i>main, server</i></p>

<p><b>description:</b> The same as so_keepalive (<a href="http://wiki.nginx.org/NginxMailCoreModule#so_keepalive">http://wiki.nginx.org/NginxMailCoreModule#so_keepalive</a>).</p>

<h3 id="tcp_nodelay">tcp_nodelay</h3>

<p><b>syntax:</b> <i>tcp_nodelay on|off</i></p>

<p><b>default:</b> <i>on</i></p>

<p><b>context:</b> <i>main, server</i></p>

<p><b>description:</b> The same as tcp_nodelay (<a href="http://wiki.nginx.org/NginxHttpCoreModule#tcp_nodelay">http://wiki.nginx.org/NginxHttpCoreModule#tcp_nodelay</a>).</p>

<h3 id="timeout">timeout</h3>

<p><b>syntax:</b> <i>timeout milliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>main, server</i></p>

<p><b>description:</b> set the timeout value with clients.</p>

<h3 id="server_name">server_name</h3>

<p><b>syntax:</b> <i>server_name name</i></p>

<p><b>default:</b> <i>The name of the host, obtained through gethostname()</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> The same as server_name (<a href="http://wiki.nginx.org/NginxMailCoreModule#server_name">http://wiki.nginx.org/NginxMailCoreModule#server_name</a>). You can specify several server name in different server block with the same port. They can be used in websocket module.</p>

<h3 id="resolver">resolver</h3>

<p><b>syntax:</b> <i>resolver address</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> DNS server</p>

<h3 id="resolver_timeout">resolver_timeout</h3>

<p><b>syntax:</b> <i>resolver_timeout time</i></p>

<p><b>default:</b> <i>30s</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> Resolver timeout in seconds.</p>

<h2 id="ngx_tcp_upstream_module">ngx_tcp_upstream_module</h2>

<h3 id="upstream">upstream</h3>

<p><b>syntax:</b> <i>upstream {...}</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp</i></p>

<p><b>description:</b> All the upstream directives are contained in this block. The upstream server will be dispatched with round robin by default.</p>

<h3 id="server1">server</h3>

<p><b>syntax:</b> <i>server name [parameters]</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> Most of the parameters are the same as server (<a href="http://wiki.nginx.org/NginxHttpUpstreamModule#server">http://wiki.nginx.org/NginxHttpUpstreamModule#server</a>). Default port is 80.</p>

<h3 id="check">check</h3>

<p><b>syntax:</b> <i>check interval=milliseconds [fall=count] [rise=count] [timeout=milliseconds] [type=tcp|ssl_hello|smtp|mysql|pop3|imap]</i></p>

<p><b>default:</b> <i>none, if parameters omitted, default parameters are interval=30000 fall=5 rise=2 timeout=1000</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> Add the health check for the upstream servers. At present, the check method is a simple tcp connect.</p>

<p>The parameters&#39; meanings are:</p>

<ul>

<li><p><i>interval</i>: the check request&#39;s interval time.</p>

</li>
<li><p><i>fall</i>(fall_count): After fall_count check failures, the server is marked down.</p>

</li>
<li><p><i>rise</i>(rise_count): After rise_count check success, the server is marked up.</p>

</li>
<li><p><i>timeout</i>: the check request&#39;s timeout.</p>

</li>
<li><p><i>type</i>: the check protocol type:</p>

<ol>

<li><p><i>tcp</i> is a simple tcp socket connect and peek one byte.</p>

</li>
<li><p><i>ssl_hello</i> sends a client ssl hello packet and receives the server ssl hello packet.</p>

</li>
<li><p><i>http</i> sends a http request packet, receives and parses the http response to diagnose if the upstream server is alive.</p>

</li>
<li><p><i>smtp</i> sends a smtp request packet, receives and parses the smtp response to diagnose if the upstream server is alive. The response begins with &#39;2&#39; should be an OK response.</p>

</li>
<li><p><i>mysql</i> connects to the mysql server, receives the greeting response to diagnose if the upstream server is alive.</p>

</li>
<li><p><i>pop3</i> receives and parses the pop3 response to diagnose if the upstream server is alive. The response begins with &#39;+&#39; should be an OK response.</p>

</li>
<li><p><i>imap</i> connects to the imap server, receives the greeting response to diagnose if the upstream server is alive.</p>

</li>
</ol>

</li>
</ul>

<h3 id="check_http_send">check_http_send</h3>

<p><b>syntax:</b> <i>check_http_send http_packet</i></p>

<p><b>default:</b> <i>&quot;GET / HTTP/1.0\r\n\r\n&quot;</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> If you set the check type is http, then the check function will sends this http packet to check the upstream server.</p>

<h3 id="check_http_expect_alive">check_http_expect_alive</h3>

<p><b>syntax:</b> <i>check_http_expect_alive [ http_2xx | http_3xx | http_4xx | http_5xx ]</i></p>

<p><b>default:</b> <i>http_2xx | http_3xx</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> These status codes indicate the upstream server&#39;s http response is OK, the backend is alive.</p>

<h3 id="check_smtp_send">check_smtp_send</h3>

<p><b>syntax:</b> <i>check_smtp_send smtp_packet</i></p>

<p><b>default:</b> <i>&quot;HELO smtp.localdomain\r\n&quot;</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> If you set the check type is smtp, then the check function will sends this smtp packet to check the upstream server.</p>

<h3 id="check_smtp_expect_alive">check_smtp_expect_alive</h3>

<p><b>syntax:</b> <i>check_smtp_expect_alive [smtp_2xx | smtp_3xx | smtp_4xx | smtp_5xx]</i></p>

<p><b>default:</b> <i>smtp_2xx</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> These status codes indicate the upstream server&#39;s smtp response is OK, the backend is alive.</p>

<h3 id="check_shm_size">check_shm_size</h3>

<p><b>syntax:</b> <i>check_shm_size size</i></p>

<p><b>default:</b> <i>(number_of_checked_upstream_blocks + 1) * pagesize</i></p>

<p><b>context:</b> <i>tcp</i></p>

<p><b>description:</b> If you store hundreds of servers in one upstream block, the shared memory for health check may be not enough, you can enlarged it by this directive.</p>

<h3 id="tcp_check_status">tcp_check_status</h3>

<p><b>syntax:</b> <i>tcp_check_status</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>location</i></p>

<p><b>description:</b> Display the health checking servers&#39; status by HTTP. This directive is set in the http block.</p>

<p>The table field meanings are:</p>

<ul>

<li><p><i>Index</i>: The server index in the check table</p>

</li>
<li><p><i>Name</i> : The upstream server name</p>

</li>
<li><p><i>Status</i>: The marked status of the server.</p>

</li>
<li><p><i>Busyness</i>: The number of connections which are connecting to the server.</p>

</li>
<li><p><i>Rise counts</i>: Count the successful checking</p>

</li>
<li><p><i>Fall counts</i>: Count the unsuccessful checking</p>

</li>
<li><p><i>Access counts</i>: Count the times accessing to this server</p>

</li>
<li><p><i>Check type</i>: The type of the check packet</p>

</li>
</ul>

<p><b>ngx_tcp_upstream_busyness_module</b></p>

<h3 id="busyness">busyness</h3>

<p><b>syntax:</b> <i>busyness</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> the upstream server will be dispatched by backend servers&#39; busyness.</p>

<p><b>ngx_tcp_upstream_ip_hash_module</b></p>

<h3 id="ip_hash">ip_hash</h3>

<p><b>syntax:</b> <i>ip_hash</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>upstream</i></p>

<p><b>description:</b> the upstream server will be dispatched by ip_hash.</p>

<h2 id="ngx_tcp_proxy_module">ngx_tcp_proxy_module</h2>

<h3 id="proxy_pass">proxy_pass</h3>

<p><b>syntax:</b> <i>proxy_pass host:port</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>server</i></p>

<p><b>description:</b> proxy the request to the backend server. Default port is 80.</p>

<h3 id="proxy_buffer">proxy_buffer</h3>

<p><b>syntax:</b> <i>proxy_buffer size</i></p>

<p><b>default:</b> <i>4k</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the size of proxy buffer.</p>

<h3 id="proxy_connect_timeout">proxy_connect_timeout</h3>

<p><b>syntax:</b> <i>proxy_connect_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of connection to backends.</p>

<h3 id="proxy_read_timeout">proxy_read_timeout</h3>

<p><b>syntax:</b> <i>proxy_read_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of reading from backends.</p>

<h3 id="proxy_send_timeout">proxy_send_timeout</h3>

<p><b>syntax:</b> <i>proxy_send_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of sending to backends.</p>

<h2 id="ngx_tcp_websocket_module">ngx_tcp_websocket_module</h2>

<h3 id="websocket_pass">websocket_pass</h3>

<p><b>syntax:</b> <i>websocket_pass [path] host:port</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>server</i></p>

<p><b>description:</b> proxy the websocket request to the backend server. Default port is 80. You can specify several different paths in the same server block.</p>

<h3 id="websocket_buffer">websocket_buffer</h3>

<p><b>syntax:</b> <i>websocket_buffer size</i></p>

<p><b>default:</b> <i>4k</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the size of proxy buffer.</p>

<h3 id="websocket_connect_timeout">websocket_connect_timeout</h3>

<p><b>syntax:</b> <i>websocket_connect_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of connection to backends.</p>

<h3 id="websocket_read_timeout">websocket_read_timeout</h3>

<p><b>syntax:</b> <i>websocket_read_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of reading from backends. Your timeout will be the minimum of this and the *timeout* parameter, so if you want a long timeout for your websockets, make sure to set both parameters.</p>

<h3 id="websocket_send_timeout">websocket_send_timeout</h3>

<p><b>syntax:</b> <i>websocket_send_timeout miliseconds</i></p>

<p><b>default:</b> <i>60000</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p><b>description:</b> set the timeout value of sending to backends.</p>

<h2 id="ngx_tcp_ssl_module">ngx_tcp_ssl_module</h2>

<p>The default config file includes this ngx_tcp_ssl_module. If you want to just compile nginx without ngx_tcp_ssl_module, copy the ngx_tcp_proxy_module/config_without_ssl to ngx_tcp_proxy_module/config, reconfigrure and compile nginx.</p>

<h3 id="ssl">ssl</h3>

<p><b>syntax:</b> <i>ssl [on|off] </i></p>

<p><b>default:</b> <i>ssl off</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>Enables SSL for a server.</p>

<h3 id="ssl_certificate">ssl_certificate</h3>

<p><b>syntax:</b> <i>ssl_certificate file</i></p>

<p><b>default:</b> <i>ssl_certificate cert.pem</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive specifies the file containing the certificate, in PEM format. This file can contain also other certificates and the server private key.</p>

<h3 id="ssl_certificate_key">ssl_certificate_key</h3>

<p><b>syntax:</b> <i>ssl_certificate_key file</i></p>

<p><b>default:</b> <i>ssl_certificate_key cert.pem</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive specifies the file containing the private key, in PEM format.</p>

<h3 id="ssl_client_certificate">ssl_client_certificate</h3>

<p><b>syntax:</b> <i>ssl_client_certificate file</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive specifies the file containing the CA (root) certificate, in PEM format, that is used for validating client certificates.</p>

<h3 id="ssl_dhparam">ssl_dhparam</h3>

<p><b>syntax:</b> <i>ssl_dhparam file</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive specifies a file containing Diffie-Hellman key agreement protocol cryptographic parameters, in PEM format, utilized for exchanging session keys between server and client.</p>

<h3 id="ssl_ciphers">ssl_ciphers</h3>

<p><b>syntax:</b> <i>ssl_ciphers openssl_cipherlist_spec</i></p>

<p><b>default:</b> <i>ssl_ciphers HIGH:!aNULL:!MD5</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive describes the list of cipher suites the server supports for establishing a secure connection. Cipher suites are specified in the OpenSSL (<a href="http://openssl.org/docs/apps/ciphers.html">http://openssl.org/docs/apps/ciphers.html</a>) cipherlist format, for example:</p>

<p>ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;</p>

<p>The complete cipherlist supported by the currently installed version of OpenSSL in your platform can be obtained by issuing the command: openssl ciphers</p>

<h3 id="ssl_crl">ssl_crl</h3>

<p><b>syntax:</b> <i>ssl_crl file</i></p>

<p><b>default:</b> <i>none</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive specifies the filename of a Certificate Revocation List, in PEM format, which is used to check the revocation status of certificates.</p>

<h3 id="ssl_prefer_server_ciphers">ssl_prefer_server_ciphers</h3>

<p><b>syntax:</b> <i>ssl_prefer_server_ciphers [on|off] </i></p>

<p><b>default:</b> <i>ssl_prefer_server_ciphers off</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>The server requires that the cipher suite list for protocols SSLv3 and TLSv1 are to be preferred over the client supported cipher suite list.</p>

<h3 id="ssl_protocols">ssl_protocols</h3>

<p><b>syntax:</b> <i>ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2]</i></p>

<p><b>default:</b> <i>ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive enables the protocol versions specified.</p>

<h3 id="ssl_verify_client">ssl_verify_client</h3>

<p><b>syntax:</b> <i>ssl_verify_client on|off|optional</i></p>

<p><b>default:</b> <i>ssl_verify_client off</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive enables the verification of the client identity. Parameter &#39;optional&#39; checks the client identity using its certificate in case it was made available to the server.</p>

<h3 id="ssl_verify_depth">ssl_verify_depth</h3>

<p><b>syntax:</b> <i>ssl_verify_depth number</i></p>

<p><b>default:</b> <i>ssl_verify_depth 1</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive sets how deep the server should go in the client provided certificate chain in order to verify the client identity.</p>

<h3 id="ssl_session_cache">ssl_session_cache</h3>

<p><b>syntax:</b> <i>ssl_session_cache off|none|builtin:size and/or shared:name:size</i></p>

<p><b>default:</b> <i>ssl_session_cache off</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>The directive sets the types and sizes of caches to store the SSL sessions.</p>

<p>The cache types are:</p>

<ul>

<li><p>off -- Hard off: nginx says explicitly to a client that sessions can not reused.</p>

</li>
<li><p>none -- Soft off: nginx says to a client that session can be reused, but nginx actually never reuses them. This is workaround for some mail clients as ssl_session_cache may be used in mail proxy as well as in HTTP server.</p>

</li>
<li><p>builtin -- the OpenSSL builtin cache, is used inside one worker process only. The cache size is assigned in the number of the sessions. Note: there appears to be a memory fragmentation issue using this method, please take that into consideration when using this. See &quot;References&quot; below.</p>

</li>
<li><p>shared -- the cache is shared between all worker processes. The size of the cache is assigned in bytes: 1 MB cache can contain roughly 4000 sessions. Each shared cache must be given an arbitrary name. A shared cache with a given name can be used in several virtual hosts.</p>

</li>
</ul>

<p>It&#39;s possible to use both types of cache &amp;mdash; builtin and shared &amp;mdash; simultaneously, for example:</p>

<p>ssl_session_cache builtin:1000 shared:SSL:10m;</p>

<p>Bear in mind however, that using only shared cache, i.e., without builtin, should be more effective.</p>

<h3 id="ssl_session_timeout">ssl_session_timeout</h3>

<p><b>syntax:</b> <i>ssl_session_timeout time</i></p>

<p><b>default:</b> <i>ssl_session_timeout 5m</i></p>

<p><b>context:</b> <i>tcp, server</i></p>

<p>This directive defines the maximum time during which the client can re-use the previously negotiated cryptographic parameters of the secure session that is stored in the SSL cache.</p>

<h1 id="Compatibility">Compatibility</h1>

<ul>

<li><p>My test bed is 0.7.65+</p>

</li>
</ul>

<h1 id="Notes">Notes</h1>

<p>The http_response_parse.rl and smtp_response_parse.rl are ragel (<a href="http://www.complang.org/ragel/">http://www.complang.org/ragel/</a>) scripts , you can edit the script and compile it like this:</p>

<pre><code>    $ ragel -G2 http_response_parse.rl
    $ ragel -G2 smtp_response_parse.rl</code></pre>

<h1 id="TODO">TODO</h1>

<ul>

<li><p>refact this module, make it more extendable for adding third-party modules</p>

</li>
<li><p>manipulate header like http module&#39;s proxy_set_header</p>

</li>
<li><p>built-in variable support</p>

</li>
<li><p>custom log format</p>

</li>
<li><p>syslog support</p>

</li>
<li><p>FTP/IRC proxying</p>

</li>
</ul>

<h1 id="Known-Issues">Known Issues</h1>

<ul>

<li><p>This module can&#39;t use the same listening port with the HTTP module.</p>

</li>
</ul>

<h1 id="Changelogs">Changelogs</h1>

<h2 id="v0.2.0">v0.2.0</h2>

<ul>

<li><p>add ssl proxy module</p>

</li>
<li><p>add websocket proxy module</p>

</li>
<li><p>add upstream busyness module</p>

</li>
<li><p>add tcp access log module</p>

</li>
</ul>

<h2 id="v0.19">v0.19</h2>

<ul>

<li><p>add many check methods</p>

</li>
</ul>

<h2 id="v0.1">v0.1</h2>

<ul>

<li><p>first release</p>

</li>
</ul>

<h1 id="Authors">Authors</h1>

<p>Weibin Yao(&#x59DA;&#x4F1F;&#x658C;) <i>yaoweibin at gmail dot com</i></p>

<h1 id="Copyright-License">Copyright &amp; License</h1>

<p>This README template copy from agentzh (<a href="http://github.com/agentzh">http://github.com/agentzh</a>).</p>

<p>I borrowed a lot of code from upstream and mail module from the nginx 0.7.* core. This part of code is copyrighted by Igor Sysoev. And the health check part is borrowed the design of Jack Lindamood&#39;s healthcheck module healthcheck_nginx_upstreams (<a href="http://github.com/cep21/healthcheck_nginx_upstreams">http://github.com/cep21/healthcheck_nginx_upstreams</a>);</p>

<p>This module is licensed under the BSD license.</p>

<p>Copyright (C) 2013 by Weibin Yao &lt;yaoweibin@gmail.com&gt;.</p>

<p>All rights reserved.</p>

<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>

<ul>

<li><p>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</p>

</li>
<li><p>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</p>

</li>
</ul>

<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>


</body>

</html>


